#include "stdio.h"
#include "stdlib.h"


#define MAXSIZE 100
typedef int DataType;

typedef struct {
    int top[2], bot[2]; //栈顶和栈底指针
    DataType *V;       //栈数组
    int m;            //栈最大可容纳元素个数
} DblStack;


int InitStack(DblStack *S, int m) {
    S->V = (DataType *)malloc(sizeof(DataType) * m);
    S->top[0] = -1;
    S->bot[0] = -1;
    S->top[1] = m;
    S->bot[1] = m;
    return 0;
}
//把x推入到栈i的栈
void push(DblStack *S, int i, DataType x) {
    S->V[i] = x;
    S->top[i] = S->bot[i] - 1;
}
//退掉位于栈i栈顶的元素
int Dblpop(DblStack *S,int i,DataType x){
    if(S->top[i] == -1)
        return -1;
    S->V[S->bot[i]] = x;
    S->bot[i] = S->top[i] - 1;
    return S->V[S->top[i]];
}

//判栈i空否, 空返回1, 否则返回0
int isEmpty(DblStack *S)
{
    if (S->top[0] == S->bot[0] && S->top[1] == S->bot[1])
        return 1;
    else
        return 0;
}

//判栈满否, 满返回1, 否则返回0
int IsFull(DblStack *S){
    if (S->top[0] == S->bot[0] && S->top[1] == S->bot[1])
        return 1;
    else
        return 0;
}

